<?php
	require_once(realpath(dirname(__FILE__)) . "/Baseobj.class.php");
	require_once(realpath(dirname(__FILE__)) . "/Messagedesc.class.php");

	class Message extends Baseobj{

		var $id;
		var $nom;
		var $protege;

		const TABLE="message";
		var $table=self::TABLE;

		var $bddvars = array("id", "nom", "protege");

		function __construct($nom = ""){
			parent::__construct();

			if($nom != "")
 			  $this->charger($nom);
		}

		function charger($nom){
			return $this->getVars("select * from $this->table where nom=\"$nom\"");
		}

		function delete($requete){
				$resul = mysql_query($requete, $this->link);
				CacheBase::getCache()->reset_cache();
		}

		function supprimer(){
            if($this->id == "")
                    return 0;

			$messagedesc =  new Messagedesc();

			$this->delete("delete from $this->table where id=\"$this->id\"");
			$this->delete("delete from $messagedesc->table where message=\"$this->id\"");

			return 1;

		}


	}

?>